#include <iostream>
#include <vector>
#include "Cheeky.h"

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    
    for (int i = 0; i < n; i++) {
        cin >> s;
        Cheeky cheeky(s);
        cout << cheeky.solution() << "\n";
    }
    return 0;
}
